/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package im.filters;

import java.util.StringTokenizer;
import im.eventpackage.Event_old;
import im.subscriptionpackage.*;

/**
 *
 * @author Giovanni
 */
public class TypeEventFilter_old {

    public TypeEventFilter_old() {
    }

    public boolean filter(Event_old event, Object type) {
        boolean ret = false;

        if (event.getType().equals(type)) {
            ret = true;
        } else {
            ret = false;
        }

        return ret;
    }

    public boolean filterSubscription(Event_old event, TypeSubscription sub) {
        boolean ret = false;

        StringTokenizer st = new StringTokenizer(sub.getHierarchy()," ");

        while (st.hasMoreTokens()) {
            String str = st.nextToken();
            if (event.getType().getClass().getSimpleName().equals(str)) {
                ret = true;
                break;
            } else {
                ret = false;
            }
        }

        return ret;
    }
}
